#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 
# Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved
# 

"""
File: selection_sort.py
Author: zhangyang(zhangyang40@baidu.com)
Date: 2017/10/30 15:06
"""


def selection_sort(items):
    """ Implementation of selection sort """
    print items
    for fillslot in range(len(items) - 1, 0, -1):
        positionOfMax = 0
        for location in range(1, fillslot + 1):
            if items[location] > items[positionOfMax]:
                positionOfMax = location

        temp = items[fillslot]
        items[fillslot] = items[positionOfMax]
        items[positionOfMax] = temp
        print items


if __name__ == '__main__':
    list2sort = [13, 14, 94, 33, 82, 25, 59, 94, 65, 23, 45, 27, 73, 25, 39, 10]

    selection_sort(list2sort)
    print list2sort
